#ifndef OPCUANODESELECT_H
#define OPCUANODESELECT_H

#include <QDialog>
#include <QOpcUaClient>
#include <QStandardItemModel>
#include <QProgressBar>

namespace Ui {
class OpcUaNodeSelect;
}

class OpcUaNodeSelect : public QDialog {
    Q_OBJECT

  public:
    explicit OpcUaNodeSelect(QOpcUaClient *client, QWidget *parent = nullptr);

    ~OpcUaNodeSelect();

    QString getValue(int role);

  private slots:
    void on_treeView_clicked(const QModelIndex &index);
    void on_btnSelected_clicked();
    void on_btnCancel_clicked();
    void on_treeView_expanded(const QModelIndex &index);

  private:
    Ui::OpcUaNodeSelect *ui;
    QStandardItemModel *model;
    QOpcUaClient *m_client;
    QOpcUaNode *root_node;
    QProgressBar *pBar;
    QString browseName, value, nodeClass, dataType, nodeId, description;

    void addRootToTree();
    void loadChildrenNode(QStandardItem *parentItem);
};

#endif // OPCUANODESELECT_H
